package org.cnbi.service.impl;

import java.util.List;

import org.cnbi.dao.IHandleDao;
import org.cnbi.entity.News;
import org.cnbi.service.INewsService;
import org.cnbi.utils.exception.BusinessException;
import org.cnbi.utils.pagination.PagingUtil;
import org.cnbi.utils.pojo.Pagination;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

@Service("newsService")
public class INewsServiceImpl implements INewsService{
	
	@Autowired
	private IHandleDao handleDao;
	
	@Override
	public Pagination queryAllNews(PagingUtil page, News news){
		try{
		    return handleDao.queryPagination(page, news);
		} catch (Exception e) {
		    throw new BusinessException("执行..查询[新闻列表]..."+page.getSql()+e.getMessage());
	    }
	}

	@Override
	public List<News> queryNews(String sql,Object obj,Object paramObj){
		try{
		    return  (List<News>) handleDao.query(sql, obj, paramObj);
	    } catch (Exception e) {
		    throw new BusinessException("执行..查询[新闻列表]..."+sql+e.getMessage());
	    }
	}

	@Override
	public void executeNews(String sql, Object obj) {
		try{
		    handleDao.execute(sql, obj);
		} catch (Exception e) {
		    throw new BusinessException("执行..添加[添加新闻]..."+sql+e.getMessage());
	    }
	}
}
